#define  _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    string multiply(string num1, string num2) {
        reverse(num1.begin(), num1.end()), reverse(num2.begin(), num2.end());
        vector<int> ret(num1.size() + num2.size(), 0);
        for (int i = 0; i < num2.size(); i++)
            for (int j = 0; j < num1.size(); j++)
                ret[i + j] += (num1[j] - '0') * (num2[i] - '0');
        int carry = 0;
        for (int i = 0; i < ret.size(); i++)
        {
            ret[i] += carry;
            carry = ret[i] / 10;
            ret[i] %= 10;
        }
        while (ret.size() != 1 && ret.back() == 0)ret.pop_back();
        reverse(ret.begin(), ret.end());
        string r;
        for (auto e : ret) r += e + '0';
        return r;
    }
};